'#############
'Window Script
'#############

'Controls the animations of windows and emergency exits.

'------------------------------------------------------------------------------------------
'----------------------
'	Trigger
'----------------------

{trigger:window_1_drag}

	(L.L.window_1_pos) (S.L.window_1_lastpos)

	(L.L.window_crank_virtual_rot) 1800 * 90 - 180 / pi * sin s0
	(L.L.window_crank_virtual_rot) 1800 * 180 / pi * sin s1
	(L.S.mouse_x) 500 / l0 * (L.S.mouse_y) -500 / l1 * + s2
	(L.L.window_crank_virtual_rot) l2 + (S.L.window_crank_virtual_rot)

	l2 0 >
	{if}
		(L.L.window_1_pos) (L.L.window_crank_virtual_rot) >
		{if}
			(L.L.window_1_pos) (S.L.window_crank_virtual_rot)
		{endif}
	{else}
		(L.L.window_1_pos) (L.L.window_crank_virtual_rot) <
		{if}
			(L.L.window_1_pos) (S.L.window_crank_virtual_rot)
		{endif}
	{endif}

	(L.L.window_1_pos) l2 + 0 max 1 min (S.L.window_1_pos) s3
	l3 0 = (L.L.window_1_lastpos) 0 > &&
	{if}
		0 (S.L.window_1_pos)
		(L.L.cp_fahrerfenster_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster_cls)
		{endif}
		1 (S.L.cp_fahrerfenster_endanschlag)
		
	{endif}
	l3 1 = (L.L.window_1_lastpos) 1 < &&
	{if}
		1 (S.L.window_1_pos)
		(L.L.cp_fahrerfenster_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster_opn)
		{endif}
		1 (S.L.cp_fahrerfenster_endanschlag)
	{endif}

	(L.L.window_1_pos) s3 0 > l3 1 < &&
	{if}
		0 (S.L.cp_fahrerfenster_endanschlag)
	{endif}


	(L.L.window_1_pos) (L.L.window_1_lastpos) - abs (L.S.Timegap) / (S.L.cp_fahrerfenster_speed)
{end}

{trigger:window_2_drag}

	(L.L.window_2_pos) (S.L.window_2_lastpos)

	(L.L.window_crank_virtual_rot) 1800 * 90 - 180 / pi * sin s0
	(L.L.window_crank_virtual_rot) 1800 * 180 / pi * sin s1
	(L.S.mouse_x) 500 / l0 * (L.S.mouse_y) -500 / l1 * + s2
	(L.L.window_crank_virtual_rot) l2 + (S.L.window_crank_virtual_rot)

	l2 0 >
	{if}
		(L.L.window_2_pos) (L.L.window_crank_virtual_rot) >
		{if}
			(L.L.window_2_pos) (S.L.window_crank_virtual_rot)
		{endif}
	{else}
		(L.L.window_2_pos) (L.L.window_crank_virtual_rot) <
		{if}
			(L.L.window_2_pos) (S.L.window_crank_virtual_rot)
		{endif}
	{endif}

	(L.L.window_2_pos) l2 + 0 max 1 min (S.L.window_2_pos) s3
	l3 0 = (L.L.window_2_lastpos) 0 > &&
	{if}
		0 (S.L.window_2_pos)
		(L.L.cp_fahrerfenster_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster_cls)
		{endif}
		1 (S.L.cp_fahrerfenster_endanschlag)
		
	{endif}
	l3 1 = (L.L.window_2_lastpos) 1 < &&
	{if}
		1 (S.L.window_2_pos)
		(L.L.cp_fahrerfenster_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster_opn)
		{endif}
		1 (S.L.cp_fahrerfenster_endanschlag)
	{endif}

	(L.L.window_2_pos) s3 0 > l3 1 < &&
	{if}
		0 (S.L.cp_fahrerfenster_endanschlag)
	{endif}


	(L.L.window_2_pos) (L.L.window_2_lastpos) - abs (L.S.Timegap) / (S.L.cp_fahrerfenster_speed)
{end}

{trigger:window_3_drag}

	(L.L.window_3_pos) (S.L.window_3_lastpos)

	(L.L.window_crank_virtual_rot) 1800 * 90 - 180 / pi * sin s0
	(L.L.window_crank_virtual_rot) 1800 * 180 / pi * sin s1
	(L.S.mouse_x) 500 / l0 * (L.S.mouse_y) -500 / l1 * + s2
	(L.L.window_crank_virtual_rot) l2 + (S.L.window_crank_virtual_rot)

	l2 0 >
	{if}
		(L.L.window_3_pos) (L.L.window_crank_virtual_rot) >
		{if}
			(L.L.window_3_pos) (S.L.window_crank_virtual_rot)
		{endif}
	{else}
		(L.L.window_3_pos) (L.L.window_crank_virtual_rot) <
		{if}
			(L.L.window_3_pos) (S.L.window_crank_virtual_rot)
		{endif}
	{endif}

	(L.L.window_3_pos) l2 + 0 max 1 min (S.L.window_3_pos) s3
	l3 0 = (L.L.window_3_lastpos) 0 > &&
	{if}
		0 (S.L.window_3_pos)
		(L.L.cp_fahrerfenster_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster_cls)
		{endif}
		1 (S.L.cp_fahrerfenster_endanschlag)
		
	{endif}
	l3 1 = (L.L.window_3_lastpos) 1 < &&
	{if}
		1 (S.L.window_3_pos)
		(L.L.cp_fahrerfenster_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster_opn)
		{endif}
		1 (S.L.cp_fahrerfenster_endanschlag)
	{endif}

	(L.L.window_3_pos) s3 0 > l3 1 < &&
	{if}
		0 (S.L.cp_fahrerfenster_endanschlag)
	{endif}


	(L.L.window_3_pos) (L.L.window_3_lastpos) - abs (L.S.Timegap) / (S.L.cp_fahrerfenster_speed)
{end}

{trigger:window_4_drag}

	(L.L.window_4_pos) (S.L.window_4_lastpos)

	(L.L.window_crank_virtual_rot) 1800 * 90 - 180 / pi * sin s0
	(L.L.window_crank_virtual_rot) 1800 * 180 / pi * sin s1
	(L.S.mouse_x) 500 / l0 * (L.S.mouse_y) -500 / l1 * + s2
	(L.L.window_crank_virtual_rot) l2 + (S.L.window_crank_virtual_rot)

	l2 0 >
	{if}
		(L.L.window_4_pos) (L.L.window_crank_virtual_rot) >
		{if}
			(L.L.window_4_pos) (S.L.window_crank_virtual_rot)
		{endif}
	{else}
		(L.L.window_4_pos) (L.L.window_crank_virtual_rot) <
		{if}
			(L.L.window_4_pos) (S.L.window_crank_virtual_rot)
		{endif}
	{endif}

	(L.L.window_4_pos) l2 + 0 max 1 min (S.L.window_4_pos) s3
	l3 0 = (L.L.window_4_lastpos) 0 > &&
	{if}
		0 (S.L.window_4_pos)
		(L.L.cp_fahrerfenster_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster_cls)
		{endif}
		1 (S.L.cp_fahrerfenster_endanschlag)
		
	{endif}
	l3 1 = (L.L.window_4_lastpos) 1 < &&
	{if}
		1 (S.L.window_4_pos)
		(L.L.cp_fahrerfenster_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster_opn)
		{endif}
		1 (S.L.cp_fahrerfenster_endanschlag)
	{endif}

	(L.L.window_4_pos) s3 0 > l3 1 < &&
	{if}
		0 (S.L.cp_fahrerfenster_endanschlag)
	{endif}


	(L.L.window_4_pos) (L.L.window_4_lastpos) - abs (L.S.Timegap) / (S.L.cp_fahrerfenster_speed)
{end}

{trigger:window_5_drag}

	(L.L.window_5_pos) (S.L.window_5_lastpos)

	(L.L.window_crank_virtual_rot) 1800 * 90 - 180 / pi * sin s0
	(L.L.window_crank_virtual_rot) 1800 * 180 / pi * sin s1
	(L.S.mouse_x) 500 / l0 * (L.S.mouse_y) -500 / l1 * + s2
	(L.L.window_crank_virtual_rot) l2 + (S.L.window_crank_virtual_rot)

	l2 0 >
	{if}
		(L.L.window_5_pos) (L.L.window_crank_virtual_rot) >
		{if}
			(L.L.window_5_pos) (S.L.window_crank_virtual_rot)
		{endif}
	{else}
		(L.L.window_5_pos) (L.L.window_crank_virtual_rot) <
		{if}
			(L.L.window_5_pos) (S.L.window_crank_virtual_rot)
		{endif}
	{endif}

	(L.L.window_5_pos) l2 + 0 max 1 min (S.L.window_5_pos) s3
	l3 0 = (L.L.window_5_lastpos) 0 > &&
	{if}
		0 (S.L.window_5_pos)
		(L.L.cp_fahrerfenster_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster_cls)
		{endif}
		1 (S.L.cp_fahrerfenster_endanschlag)
		
	{endif}
	l3 1 = (L.L.window_5_lastpos) 1 < &&
	{if}
		1 (S.L.window_5_pos)
		(L.L.cp_fahrerfenster_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster_opn)
		{endif}
		1 (S.L.cp_fahrerfenster_endanschlag)
	{endif}

	(L.L.window_5_pos) s3 0 > l3 1 < &&
	{if}
		0 (S.L.cp_fahrerfenster_endanschlag)
	{endif}


	(L.L.window_5_pos) (L.L.window_5_lastpos) - abs (L.S.Timegap) / (S.L.cp_fahrerfenster_speed)
{end}

{trigger:window_6_drag}

	(L.L.window_6_pos) (S.L.window_6_lastpos)

	(L.L.window_crank_virtual_rot) 1800 * 90 - 180 / pi * sin s0
	(L.L.window_crank_virtual_rot) 1800 * 180 / pi * sin s1
	(L.S.mouse_x) 500 / l0 * (L.S.mouse_y) -500 / l1 * + s2
	(L.L.window_crank_virtual_rot) l2 + (S.L.window_crank_virtual_rot)

	l2 0 >
	{if}
		(L.L.window_6_pos) (L.L.window_crank_virtual_rot) >
		{if}
			(L.L.window_6_pos) (S.L.window_crank_virtual_rot)
		{endif}
	{else}
		(L.L.window_6_pos) (L.L.window_crank_virtual_rot) <
		{if}
			(L.L.window_6_pos) (S.L.window_crank_virtual_rot)
		{endif}
	{endif}

	(L.L.window_6_pos) l2 + 0 max 1 min (S.L.window_6_pos) s3
	l3 0 = (L.L.window_6_lastpos) 0 > &&
	{if}
		0 (S.L.window_6_pos)
		(L.L.cp_fahrerfenster_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster_cls)
		{endif}
		1 (S.L.cp_fahrerfenster_endanschlag)
		
	{endif}
	l3 1 = (L.L.window_6_lastpos) 1 < &&
	{if}
		1 (S.L.window_6_pos)
		(L.L.cp_fahrerfenster_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster_opn)
		{endif}
		1 (S.L.cp_fahrerfenster_endanschlag)
	{endif}

	(L.L.window_6_pos) s3 0 > l3 1 < &&
	{if}
		0 (S.L.cp_fahrerfenster_endanschlag)
	{endif}


	(L.L.window_6_pos) (L.L.window_6_lastpos) - abs (L.S.Timegap) / (S.L.cp_fahrerfenster_speed)
{end}

{trigger:window_7_drag}

	(L.L.window_7_pos) (S.L.window_7_lastpos)

	(L.L.window_crank_virtual_rot) 1800 * 90 - 180 / pi * sin s0
	(L.L.window_crank_virtual_rot) 1800 * 180 / pi * sin s1
	(L.S.mouse_x) 500 / l0 * (L.S.mouse_y) -500 / l1 * + s2
	(L.L.window_crank_virtual_rot) l2 + (S.L.window_crank_virtual_rot)

	l2 0 >
	{if}
		(L.L.window_7_pos) (L.L.window_crank_virtual_rot) >
		{if}
			(L.L.window_7_pos) (S.L.window_crank_virtual_rot)
		{endif}
	{else}
		(L.L.window_7_pos) (L.L.window_crank_virtual_rot) <
		{if}
			(L.L.window_7_pos) (S.L.window_crank_virtual_rot)
		{endif}
	{endif}

	(L.L.window_7_pos) l2 + 0 max 1 min (S.L.window_7_pos) s3
	l3 0 = (L.L.window_7_lastpos) 0 > &&
	{if}
		0 (S.L.window_7_pos)
		(L.L.cp_fahrerfenster_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster_cls)
		{endif}
		1 (S.L.cp_fahrerfenster_endanschlag)
		
	{endif}
	l3 1 = (L.L.window_7_lastpos) 1 < &&
	{if}
		1 (S.L.window_7_pos)
		(L.L.cp_fahrerfenster_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster_opn)
		{endif}
		1 (S.L.cp_fahrerfenster_endanschlag)
	{endif}

	(L.L.window_7_pos) s3 0 > l3 1 < &&
	{if}
		0 (S.L.cp_fahrerfenster_endanschlag)
	{endif}


	(L.L.window_7_pos) (L.L.window_7_lastpos) - abs (L.S.Timegap) / (S.L.cp_fahrerfenster_speed)
{end}

{trigger:window_8_drag}

	(L.L.window_8_pos) (S.L.window_8_lastpos)

	(L.L.window_crank_virtual_rot) 1800 * 90 - 180 / pi * sin s0
	(L.L.window_crank_virtual_rot) 1800 * 180 / pi * sin s1
	(L.S.mouse_x) 500 / l0 * (L.S.mouse_y) -500 / l1 * + s2
	(L.L.window_crank_virtual_rot) l2 + (S.L.window_crank_virtual_rot)

	l2 0 >
	{if}
		(L.L.window_8_pos) (L.L.window_crank_virtual_rot) >
		{if}
			(L.L.window_8_pos) (S.L.window_crank_virtual_rot)
		{endif}
	{else}
		(L.L.window_8_pos) (L.L.window_crank_virtual_rot) <
		{if}
			(L.L.window_8_pos) (S.L.window_crank_virtual_rot)
		{endif}
	{endif}

	(L.L.window_8_pos) l2 + 0 max 1 min (S.L.window_8_pos) s3
	l3 0 = (L.L.window_8_lastpos) 0 > &&
	{if}
		0 (S.L.window_8_pos)
		(L.L.cp_fahrerfenster_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster_cls)
		{endif}
		1 (S.L.cp_fahrerfenster_endanschlag)
		
	{endif}
	l3 1 = (L.L.window_8_lastpos) 1 < &&
	{if}
		1 (S.L.window_8_pos)
		(L.L.cp_fahrerfenster_endanschlag) !
		{if}
			(T.L.ev_fahrerfenster_opn)
		{endif}
		1 (S.L.cp_fahrerfenster_endanschlag)
	{endif}

	(L.L.window_8_pos) s3 0 > l3 1 < &&
	{if}
		0 (S.L.cp_fahrerfenster_endanschlag)
	{endif}


	(L.L.window_8_pos) (L.L.window_8_lastpos) - abs (L.S.Timegap) / (S.L.cp_fahrerfenster_speed)
{end}


{trigger:window_1_off}
{trigger:window_2_off}
{trigger:window_3_off}
{trigger:window_4_off}
{trigger:window_5_off}
{trigger:window_6_off}
{trigger:window_7_off}
{trigger:window_8_off}
	0 (S.L.cp_fahrerfenster_speed)
{end}
{end}
{end}
{end}
{end}
{end}
{end}
{end}

{trigger:emg_door_lock_drag}
	1 (S.L.emg_door_lock_dragged)
	(L.L.emg_door_lock_handle) (L.S.mouse_y) 100 / + 0 max 1 min (S.L.emg_door_lock_handle)
{trigger:emg_door_L_drag}
	1 (S.L.emg_door_L_dragged)

	(L.L.emg_door_L_pos) (S.L.emg_door_L_lastpos)

	(L.L.emg_door_L_pos) 0 > (L.L.emg_door_lock_tenon) 0.95 >= ||
	{if}
		(L.S.mouse_x) -400 / (L.L.emg_door_L_pos) + 0 max 1 min (S.L.emg_door_L_pos)
	{endif}

	(L.L.emg_door_L_pos) 1 >= (L.L.emg_door_L_lastpos) 1 < &&
	{if}
		(T.L.emg_door_L_hit)
		(L.L.emg_door_L_pos) 1 min (S.L.emg_door_L_pos)
	{endif}
	(L.L.emg_door_L_pos) 0 <= (L.L.emg_door_L_lastpos) 0 > &&
	{if}
		(T.L.emg_door_L_hit)
		(L.L.emg_door_L_pos) 0 max (S.L.emg_door_L_pos)
	{endif}
	(L.L.emg_door_L_pos) 0 > (L.L.emg_door_L_lastpos) 0 = &&
	{if}
		(T.L.emg_door_L_open)
	{endif}

	(L.L.emg_door_L_pos) (L.L.emg_door_L_lastpos) - (L.S.Timegap) / (S.L.emg_door_L_speed)
{end}
{end}

{trigger:emg_door_lock_off}
{trigger:emg_door_L_off}
	0 (S.L.emg_door_L_dragged) (S.L.emg_door_lock_dragged)
{end}
{end}

{trigger:emg_door_U_drag}
	1 (S.L.emg_door_U_dragged)

	(L.L.emg_door_U_pos) (S.L.emg_door_U_lastpos)
	(L.S.mouse_y) -300 / (L.L.emg_door_U_pos) + 0 max 1 min (S.L.emg_door_U_pos)

	(L.L.emg_door_U_pos) 1 >= (L.L.emg_door_U_lastpos) 1 < &&
	{if}
		(T.L.emg_door_L_hit)
		(L.L.emg_door_U_pos) 1 min (S.L.emg_door_U_pos)
	{endif}
	(L.L.emg_door_U_pos) 0 <= (L.L.emg_door_U_lastpos) 0 > &&
	{if}
		(T.L.emg_door_L_hit)
		(L.L.emg_door_U_pos) 0 max (S.L.emg_door_U_pos)
	{endif}
	(L.L.emg_door_U_pos) 0 > (L.L.emg_door_U_lastpos) 0 = &&
	{if}
		(T.L.emg_door_L_open)
	{endif}

	(L.L.emg_door_U_pos) (L.L.emg_door_U_lastpos) - (L.S.Timegap) / (S.L.emg_door_U_speed)
{end}

{trigger:emg_door_U_off}
	0 (S.L.emg_door_U_dragged)
{end}

{trigger:driver_door_lock_drag}
	1 (S.L.driver_door_lock_dragged)
	(L.L.driver_door_lock_handle) (L.S.mouse_y) 100 / + 0 max 1 min (S.L.driver_door_lock_handle)
{trigger:driver_door_drag}
	1 (S.L.driver_door_dragged)

	(L.L.driver_door_pos) (S.L.driver_door_lastpos)

	(L.L.driver_door_pos) 0 > (L.L.driver_door_lock_tenon) 0.95 >= ||
	{if}
		(L.S.mouse_x) 400 / (L.L.driver_door_pos) + 0 max 1 min (S.L.driver_door_pos)
	{endif}

	(L.L.driver_door_pos) 1 >= (L.L.driver_door_lastpos) 1 < &&
	{if}
		(T.L.emg_door_L_hit)
		(L.L.driver_door_pos) 1 min (S.L.driver_door_pos)
	{endif}
	(L.L.driver_door_pos) 0 <= (L.L.driver_door_lastpos) 0 > &&
	{if}
		(T.L.emg_door_L_hit)
		(L.L.driver_door_pos) 0 max (S.L.driver_door_pos)
	{endif}
	(L.L.driver_door_pos) 0 > (L.L.driver_door_lastpos) 0 = &&
	{if}
		(T.L.emg_door_L_open)
	{endif}

	(L.L.driver_door_pos) (L.L.driver_door_lastpos) - (L.S.Timegap) / (S.L.driver_door_speed)
{end}
{end}

{trigger:driver_door_lock_off}
{trigger:driver_door_off}
	0 (S.L.driver_door_dragged) (S.L.driver_door_lock_dragged)
{end}
{end}

{trigger:passenger_door_control_drag}
	1 (S.L.passenger_door_dragged) (S.L.passenger_door_control_dragged) (S.L.passenger_door_lock_tenon)

	(L.L.passenger_door_pos) (S.L.passenger_door_lastpos)

	(L.S.mouse_x) 400 / (L.L.passenger_door_pos) + 0 max 1 min (S.L.passenger_door_pos)

	(L.L.passenger_door_pos) 1 >= (L.L.passenger_door_lastpos) 1 < &&
	{if}
		(T.L.emg_door_L_hit)
		(L.L.passenger_door_pos) 1 min (S.L.passenger_door_pos)
	{endif}
	(L.L.passenger_door_pos) 0 <= (L.L.passenger_door_lastpos) 0 > &&
	{if}
		(T.L.emg_door_L_hit)
		(L.L.passenger_door_pos) 0 max (S.L.passenger_door_pos)
	{endif}
	(L.L.passenger_door_pos) 0 > (L.L.passenger_door_lastpos) 0 = &&
	{if}
		(T.L.emg_door_L_open)
	{endif}

	(L.L.passenger_door_pos) (L.L.passenger_door_lastpos) - (L.S.Timegap) / (S.L.passenger_door_speed)
{end}

{trigger:passenger_door_lock_drag}
	1 (S.L.passenger_door_lock_dragged)
	(L.L.passenger_door_lock_handle) (L.S.mouse_y) 100 / + 0 max 1 min (S.L.passenger_door_lock_handle)
{trigger:passenger_door_drag}
	1 (S.L.passenger_door_dragged)

	(L.L.passenger_door_pos) (S.L.passenger_door_lastpos)

	(L.L.passenger_door_pos) 0 > (L.L.passenger_door_lock_tenon) 0.95 >= ||
	{if}
		(L.S.mouse_x) 400 / (L.L.passenger_door_pos) + 0 max 1 min (S.L.passenger_door_pos)
	{endif}

	(L.L.passenger_door_pos) 1 >= (L.L.passenger_door_lastpos) 1 < &&
	{if}
		(T.L.emg_door_L_hit)
		(L.L.passenger_door_pos) 1 min (S.L.passenger_door_pos)
	{endif}
	(L.L.passenger_door_pos) 0 <= (L.L.passenger_door_lastpos) 0 > &&
	{if}
		(T.L.emg_door_L_hit)
		(L.L.passenger_door_pos) 0 max (S.L.passenger_door_pos)
	{endif}
	(L.L.passenger_door_pos) 0 > (L.L.passenger_door_lastpos) 0 = &&
	{if}
		(T.L.emg_door_L_open)
	{endif}

	(L.L.passenger_door_pos) (L.L.passenger_door_lastpos) - (L.S.Timegap) / (S.L.passenger_door_speed)
{end}
{end}

{trigger:passenger_door_control_off}
{trigger:passenger_door_lock_off}
{trigger:passenger_door_off}
	0 (S.L.passenger_door_dragged) (S.L.passenger_door_lock_dragged) (S.L.passenger_door_control_dragged)
{end}
{end}
{end}

{trigger:bus_doorfront0}
{trigger:bus_doorfront1}
{trigger:bus_dooraft}
	(L.L.passenger_door_target) ! (S.L.passenger_door_target)
	(L.L.passenger_door_target)
	{if}
		(L.L.passenger_door_pos) 0 =
		{if}
			(T.L.emg_door_L_open)
		{endif}
		(L.L.passenger_door_pos) 0.01 max (S.L.passenger_door_pos)
		(L.L.passenger_door_speed) 0.8 max (S.L.passenger_door_speed)
	{else}
		(L.L.passenger_door_pos) 0 >
		{if}
			(L.L.passenger_door_speed) -0.8 min (S.L.passenger_door_speed)
		{endif}
	{endif}
{end}
{end}
{end}

{trigger:engine_cover_L_drag}
	1 (S.L.engine_cover_L_dragged)

	(L.L.engine_cover_L_pos) (S.L.engine_cover_L_lastpos)

	(L.L.engine_cover_L_pos) (L.S.mouse_y) -250 / + 1 min 0 max (S.L.engine_cover_L_pos)
	(L.L.engine_cover_R_pos) 80 90 (L.L.engine_cover_L_pos) 170 * - + 170 / min 0 max (S.L.engine_cover_R_pos)

	(L.L.engine_cover_L_pos) 1 >= (L.L.engine_cover_L_lastpos) 1 < &&
	{if}
		(T.L.emg_door_L_hit)
		(L.L.engine_cover_L_pos) 1 min (S.L.engine_cover_L_pos)
	{endif}
	(L.L.engine_cover_L_pos) 0 <= (L.L.engine_cover_L_lastpos) 0 > &&
	{if}
		(T.L.emg_door_L_hit)
		(L.L.engine_cover_L_pos) 0 max (S.L.engine_cover_L_pos)
	{endif}
	(L.L.engine_cover_R_pos) 80 90 (L.L.engine_cover_L_pos) 170 * - + 170 / >=
	{if}
		(L.L.engine_cover_R_speed) (L.L.engine_cover_R_pos) (L.L.engine_cover_R_lastpos) - (L.S.Timegap) / min (S.L.engine_cover_R_speed)
	{endif}

	(L.L.engine_cover_L_pos) (L.L.engine_cover_L_lastpos) - (L.S.Timegap) / (S.L.engine_cover_L_speed)
{end}

{trigger:engine_cover_R_drag}
	1 (S.L.engine_cover_R_dragged)

	(L.L.engine_cover_R_pos) (S.L.engine_cover_R_lastpos)

	(L.L.engine_cover_R_pos) (L.S.mouse_y) -250 / + 1 min 0 max (S.L.engine_cover_R_pos)
	(L.L.engine_cover_L_pos) 80 90 (L.L.engine_cover_R_pos) 170 * - + 170 / min 0 max (S.L.engine_cover_L_pos)

	(L.L.engine_cover_R_pos) 1 >= (L.L.engine_cover_R_lastpos) 1 < &&
	{if}
		(T.L.emg_door_L_hit)
		(L.L.engine_cover_R_pos) 1 min (S.L.engine_cover_R_pos)
	{endif}
	(L.L.engine_cover_R_pos) 0 <= (L.L.engine_cover_R_lastpos) 0 > &&
	{if}
		(T.L.emg_door_L_hit)
		(L.L.engine_cover_R_pos) 0 max (S.L.engine_cover_R_pos)
	{endif}
	(L.L.engine_cover_L_pos) 80 90 (L.L.engine_cover_R_pos) 170 * - + 170 / >=
	{if}
		(L.L.engine_cover_L_speed) (L.L.engine_cover_L_pos) (L.L.engine_cover_L_lastpos) - (L.S.Timegap) / min (S.L.engine_cover_L_speed)
	{endif}

	(L.L.engine_cover_R_pos) (L.L.engine_cover_R_lastpos) - (L.S.Timegap) / (S.L.engine_cover_R_speed)
{end}

{trigger:engine_cover_L_off}
{trigger:engine_cover_R_off}
	0 (S.L.engine_cover_L_dragged) (S.L.engine_cover_R_dragged)
{end}
{end}
'----------------------
'	Frame
'----------------------

{macro:window_frame}

'---------------
'Emergency door:
'---------------

	(L.L.emg_door_lock_dragged) !
	{if}
		(L.L.emg_door_lock_handle) (L.S.Timegap) 2 (L.L.emg_door_lock_handle) - 3 * * - 0 max 1 min (S.L.emg_door_lock_handle)
	{endif}
	(L.L.emg_door_L_pos) 0 > (L.L.emg_door_L_pos) 0.011 <= &&
	{if}
		(L.L.emg_door_lock_handle) 2 / 0.5 + 1.75 (L.L.emg_door_L_pos) 0.0088 / - max 1 min (S.L.emg_door_lock_tenon)
	{else}
		(L.L.emg_door_lock_handle) 2 / 0.5 + 0.5 max 1 min (S.L.emg_door_lock_tenon)
	{endif}
	(L.L.emg_door_L_dragged) !
	{if}
        	(L.L.emg_door_L_pos) (L.S.Timegap) (L.L.emg_door_L_speed) * + 0 max 1 min (S.L.emg_door_L_pos)

		(L.L.emg_door_L_pos) 1 >=
		{if}
		        (L.L.emg_door_L_lastpos) 1 <
		        {if}
				(T.L.emg_door_L_hit)
				1 (S.L.emg_door_L_pos)
        		{endif}
			(L.L.emg_door_L_speed) -0.5 * (S.L.emg_door_L_speed)
			(L.L.emg_door_L_speed) 0 min (S.L.emg_door_L_speed)
		{endif}
		(L.L.emg_door_L_pos) 0 <=
		{if}
		        (L.L.emg_door_L_lastpos) 0 >
		        {if}
			        (T.L.emg_door_L_hit)
			        0 (S.L.emg_door_L_pos)
        		{endif}
			0 (S.L.emg_door_L_speed)
		{endif}

		(L.L.emg_door_L_speed) (L.L.A_Trans_Y) (L.L.emg_door_L_globalangle_Y) * (L.L.A_Trans_X) (L.L.emg_door_L_globalangle_X) * + 0.3 * (L.S.Timegap) * + (S.L.emg_door_L_speed)
	
		(L.L.emg_door_L_speed) s1 (S.L.emg_door_L_lastspeed)
		l1 0 >
		{if}
			l1 (L.S.Timegap) 0.3 * - (S.L.emg_door_L_speed)
		{endif}
		l1 0 <
		{if}
			l1 (L.S.Timegap) 0.3 * + (S.L.emg_door_L_speed)
		{endif}

		(L.L.emg_door_L_speed) 0 > (L.L.emg_door_L_lastspeed) 0 < &&
		(L.L.emg_door_L_speed) 0 < (L.L.emg_door_L_lastspeed) 0 > && ||
		(L.L.emg_door_L_pos) 0 <= (L.L.emg_door_lock_tenon) 0.95 < && ||
		{if}
			0 (S.L.emg_door_L_speed)
		{endif}	 

	        (L.L.emg_door_L_pos) (S.L.emg_door_L_lastpos)
	
	{endif}

	(L.L.emg_door_L_pos) 120 * pi * 180 / sin (S.L.emg_door_L_globalangle_X)
	(L.L.emg_door_L_pos) 120 * 90 + pi * 180 / sin (S.L.emg_door_L_globalangle_Y)

'-----------------
'Spare tyre cover:
'-----------------

	(L.L.emg_door_U_dragged) ! (L.L.emg_door_U_pos) 0 > &&
	{if}
		(L.L.emg_door_U_pos) (L.S.Timegap) (L.L.emg_door_U_speed) * + 0 max 1 min (S.L.emg_door_U_pos)

		(L.L.emg_door_U_pos) 1 >=
		{if}
			(L.L.emg_door_U_lastpos) 1 <
			{if}
		        	(T.L.emg_door_L_hit)
				1 (S.L.emg_door_U_pos)
		        {endif}
			(L.L.emg_door_U_speed) -0.25 * (S.L.emg_door_U_speed)
		{endif}
		(L.L.emg_door_U_pos) 0 <=
		{if}
			(L.L.emg_door_U_lastpos) 0 >
			{if}
		        	(T.L.emg_door_L_hit)
				0 (S.L.emg_door_U_pos)
		        {endif}
			(L.L.emg_door_U_speed) -0.5 * (S.L.emg_door_U_speed)
		{endif}

 		(L.L.emg_door_U_speed) (L.L.A_Trans_Y) (L.L.emg_door_U_globalangle_Y) * (L.L.A_Trans_Z) /-/ 9.80665 - (L.L.emg_door_U_globalangle_Z) * + (L.S.Timegap) * + (S.L.emg_door_U_speed)

		(L.L.emg_door_U_speed) s1 (S.L.emg_door_U_lastspeed)
		l1 0 >
		{if}
			l1 (L.S.Timegap) 0.3 * - (S.L.emg_door_U_speed)
		{endif}
		l1 0 <
		{if}
			l1 (L.S.Timegap) 0.3 * + (S.L.emg_door_U_speed)
		{endif}

		(L.L.emg_door_U_speed) 0 > (L.L.emg_door_U_lastspeed) 0 < &&
		(L.L.emg_door_U_speed) 0 < (L.L.emg_door_U_lastspeed) 0 > && ||
		{if}
			0 (S.L.emg_door_U_speed)
		{endif}	

	        (L.L.emg_door_U_pos) (S.L.emg_door_U_lastpos)
	
	{endif}

	(L.L.emg_door_U_pos) 100 * 70 + pi * 180 / sin (S.L.emg_door_U_globalangle_Y)
	(L.L.emg_door_U_pos) 100 * 20 - pi * 180 / sin (S.L.emg_door_U_globalangle_Z)

'---------
'Mudguard:
'---------

	(L.L.mudguard_L_pos) (L.S.Timegap) (L.L.mudguard_L_speed) * + -1 max 1 min (S.L.mudguard_L_pos)

	(L.L.mudguard_L_pos) 1 >=
	{if}
		(L.L.mudguard_L_speed) -0.75 * (S.L.mudguard_L_speed)
	{endif}
	(L.L.mudguard_L_pos) -1 <=
	{if}
		(L.L.mudguard_L_speed) -0.5 * (S.L.mudguard_L_speed)
	{endif}

 	(L.L.mudguard_L_speed) (L.L.A_Trans_Y) (L.L.Velocity_Ground) 0.05 * + (L.L.mudguard_L_globalangle_Y) * (L.L.A_Trans_Z) /-/ 9.80665 - (L.L.mudguard_L_globalangle_Z) * + (L.S.Timegap) * + (S.L.mudguard_L_speed)

	(L.L.mudguard_L_speed) s1 (S.L.mudguard_L_lastspeed)
	l1 0 >
	{if}
		l1 (L.S.Timegap) 0.4 * - (S.L.mudguard_L_speed)
	{endif}
	l1 0 <
	{if}
		l1 (L.S.Timegap) 0.5 * + (S.L.mudguard_L_speed)
	{endif}

	(L.L.mudguard_L_speed) 0 > (L.L.mudguard_L_lastspeed) 0 < &&
	(L.L.mudguard_L_speed) 0 < (L.L.mudguard_L_lastspeed) 0 > && ||
	{if}
		0 (S.L.mudguard_L_speed)
	{endif}

	(L.L.mudguard_L_pos) 30 * 90 + pi * 180 / sin (S.L.mudguard_L_globalangle_Y)
	(L.L.mudguard_L_pos) 30 * pi * 180 / sin (S.L.mudguard_L_globalangle_Z)

	(L.L.mudguard_R_pos) (L.S.Timegap) (L.L.mudguard_R_speed) * + -1 max 1 min (S.L.mudguard_R_pos)

	(L.L.mudguard_R_pos) 1 >=
	{if}
		(L.L.mudguard_R_speed) -0.5 * (S.L.mudguard_R_speed)
	{endif}
	(L.L.mudguard_R_pos) -1 <=
	{if}
		(L.L.mudguard_R_speed) -0.75 * (S.L.mudguard_R_speed)
	{endif}

 	(L.L.mudguard_R_speed) (L.L.A_Trans_Y) (L.L.Velocity_Ground) 0.05 * + (L.L.mudguard_R_globalangle_Y) * (L.L.A_Trans_Z) /-/ 9.80665 - (L.L.mudguard_R_globalangle_Z) * + (L.S.Timegap) * + (S.L.mudguard_R_speed)

	(L.L.mudguard_R_speed) s1 (S.L.mudguard_R_lastspeed)
	l1 0 >
	{if}
		l1 (L.S.Timegap) 0.5 * - (S.L.mudguard_R_speed)
	{endif}
	l1 0 <
	{if}
		l1 (L.S.Timegap) 0.4 * + (S.L.mudguard_R_speed)
	{endif}

	(L.L.mudguard_R_speed) 0 > (L.L.mudguard_R_lastspeed) 0 < &&
	(L.L.mudguard_R_speed) 0 < (L.L.mudguard_R_lastspeed) 0 > && ||
	{if}
		0 (S.L.mudguard_R_speed)
	{endif}	

	(L.L.mudguard_R_pos) 30 * 90 + pi * 180 / sin (S.L.mudguard_R_globalangle_Y)
	(L.L.mudguard_R_pos) 30 * pi * 180 / sin (S.L.mudguard_R_globalangle_Z)

'------------
'Driver door:
'------------

	(L.L.driver_door_lock_dragged) !
	{if}
		(L.L.driver_door_lock_handle) (L.S.Timegap) 2 (L.L.driver_door_lock_handle) - 3 * * - 0 max 1 min (S.L.driver_door_lock_handle)
	{endif}
	(L.L.driver_door_pos) 0 > (L.L.driver_door_pos) 0.017 <= &&
	{if}
		(L.L.driver_door_lock_handle) 2 / 0.5 + 2.625 (L.L.driver_door_pos) 0.008 / - max 1 min (S.L.driver_door_lock_tenon)
	{else}
		(L.L.driver_door_lock_handle) 2 / 0.5 + 0.5 max 1 min (S.L.driver_door_lock_tenon)
	{endif}
	(L.L.driver_door_dragged) !
	{if}
        	(L.L.driver_door_pos) (L.S.Timegap) (L.L.driver_door_speed) * + 0 max 1 min (S.L.driver_door_pos)

		(L.L.driver_door_pos) 1 >=
		{if}
		        (L.L.driver_door_lastpos) 1 <
		        {if}
				(T.L.emg_door_L_hit)
				1 (S.L.driver_door_pos)
        		{endif}
			(L.L.driver_door_speed) -0.5 * (S.L.driver_door_speed)
			(L.L.driver_door_speed) 0 min (S.L.driver_door_speed)
		{endif}
		(L.L.driver_door_pos) 0 <=
		{if}
		        (L.L.driver_door_lastpos) 0 >
		        {if}
			        (T.L.emg_door_L_hit)
			        0 (S.L.driver_door_pos)
        		{endif}
			0 (S.L.driver_door_speed)
		{endif}

		(L.L.driver_door_speed) (L.L.A_Trans_Y) /-/ (L.L.driver_door_globalangle_Y) * (L.L.A_Trans_X) (L.L.driver_door_globalangle_X) * + 0.3 * (L.S.Timegap) * + (S.L.driver_door_speed)
	
		(L.L.driver_door_speed) s1 (S.L.driver_door_lastspeed)
		l1 0 >
		{if}
			l1 (L.S.Timegap) 0.3 * - (S.L.driver_door_speed)
		{endif}
		l1 0 <
		{if}
			l1 (L.S.Timegap) 0.3 * + (S.L.driver_door_speed)
		{endif}

		(L.L.driver_door_speed) 0 > (L.L.driver_door_lastspeed) 0 < &&
		(L.L.driver_door_speed) 0 < (L.L.driver_door_lastspeed) 0 > && ||
		(L.L.driver_door_pos) 0 <= (L.L.driver_door_lock_tenon) 0.95 < && ||
		{if}
			0 (S.L.driver_door_speed)
		{endif}	 

	        (L.L.driver_door_pos) (S.L.driver_door_lastpos)
	
	{endif}

	(L.L.driver_door_pos) 80 * 108.13 + pi * 180 / sin (S.L.driver_door_globalangle_X)
	(L.L.driver_door_pos) 80 * 18.13 + pi * 180 / sin (S.L.driver_door_globalangle_Y)

'---------------
'Passenger door:
'---------------
(L.L.AI_Scheduled_AtStation) s0
1 =
{if}
'Wenn Türen geöffnet werden sollen:
	(L.L.Velocity) 5 <
	{if}
'Nur, wenn v < maxkmh, sonst warten
'Taster jeweils nur betätigen, falls noch nicht an
		(L.L.passenger_door_target) ! (L.L.door_AI_timer) 0.6 > &&
		{if}
			1 (S.L.passenger_door_target)
		{endif}
		(L.L.passenger_door_target)
		{if}
			(L.L.passenger_door_pos) 0 =
			{if}
				(T.L.emg_door_L_open)
			{endif}
			(L.L.passenger_door_pos) 0.01 max (S.L.passenger_door_pos)
			(L.L.passenger_door_pos) 0.7 <
			{if}
				(L.L.passenger_door_speed) (L.S.Timegap) + 0.5 min (S.L.passenger_door_speed)
			{endif}
		{endif}
	{else}
		0 (S.L.door_AI_timer)
	{endif}
	(L.L.door_AI_timer) (L.S.Timegap) + (S.L.door_AI_timer)
{else}
l0 -1 =
{if}
'Wenn Türen geschlossen werden sollen:
'Taster jeweils nur betätigen, falls noch nicht aus:
	(L.L.passenger_door_target)
	{if}
		0 (S.L.passenger_door_target)
		0 (S.L.door_AI_timer)
	{endif}
	(L.L.passenger_door_target) !
	{if}
		(L.L.passenger_door_pos) 0 >
		{if}
			(L.L.passenger_door_speed) (L.S.Timegap) - -0.5 max (S.L.passenger_door_speed)
		{endif}
	{endif}
'Haltestellenbremse erst wegnehmen, wenn alle Türen zu. Dann auch erst den Bus AI-mäßig freigeben:
	(L.L.passenger_door_pos) 0.1 <
	{if}
		(L.L.passenger_door_target) !
		{if}
			0 (S.L.AI_Scheduled_AtStation)
		{endif}
	{else}
'Sollte eine der Türen auf sein und die Haltestellenbremse aus, dann sofort diese einlegen
		(L.L.passenger_door_target) !
		{if}
			0 (S.L.door_AI_timer)
		{endif}
	{endif}
	(L.L.door_AI_timer) (L.S.Timegap) + (S.L.door_AI_timer)
{endif}
{endif}
	(L.L.passenger_door_pos) 0 =
	{if}
		0 (S.L.passenger_door_target)
	{endif}
	(L.L.passenger_door_lock_dragged) !
	{if}
		(L.L.passenger_door_lock_handle) (L.S.Timegap) 2 (L.L.passenger_door_lock_handle) - 3 * * - 0 max 1 min (S.L.passenger_door_lock_handle)
	{endif}
	(L.L.passenger_door_pos) 0 > (L.L.passenger_door_pos) 0.0272 <= &&
	{if}
		(L.L.passenger_door_lock_handle) 2 / 0.5 + 2.625 (L.L.passenger_door_pos) 0.0128 / - max 1 min (S.L.passenger_door_lock_tenon)
	{else}
		(L.L.passenger_door_lock_handle) 2 / 0.5 + 0.5 max 1 min (S.L.passenger_door_lock_tenon)
	{endif}
	(L.L.passenger_door_dragged) !
	{if}
        	(L.L.passenger_door_pos) (L.S.Timegap) (L.L.passenger_door_speed) * + 0 max 1 min (S.L.passenger_door_pos)

		(L.L.passenger_door_pos) 1 >=
		{if}
		        (L.L.passenger_door_lastpos) 1 <
		        {if}
				(T.L.emg_door_L_hit)
				1 (S.L.passenger_door_pos)
        		{endif}
			(L.L.passenger_door_speed) -0.5 * (S.L.passenger_door_speed)
			(L.L.passenger_door_speed) 0 min (S.L.passenger_door_speed)
		{endif}
		(L.L.passenger_door_pos) 0 <=
		{if}
		        (L.L.passenger_door_lastpos) 0 >
		        {if}
			        (T.L.emg_door_L_hit)
			        0 (S.L.passenger_door_pos)
        		{endif}
			0 (S.L.passenger_door_speed)
		{endif}

		(L.L.passenger_door_speed) (L.L.A_Trans_Y) /-/ (L.L.passenger_door_globalangle_Y) * (L.L.A_Trans_X) /-/ (L.L.passenger_door_globalangle_X) * + 0.3 * (L.S.Timegap) * + (S.L.passenger_door_speed)
	
		(L.L.passenger_door_speed) s1 (S.L.passenger_door_lastspeed)
		l1 0 >
		{if}
			l1 (L.S.Timegap) 0.3 * - (S.L.passenger_door_speed)
		{endif}
		l1 0 <
		{if}
			l1 (L.S.Timegap) 0.3 * + (S.L.passenger_door_speed)
		{endif}

		(L.L.passenger_door_speed) 0 > (L.L.passenger_door_lastspeed) 0 < &&
		(L.L.passenger_door_speed) 0 < (L.L.passenger_door_lastspeed) 0 > && ||
		(L.L.passenger_door_pos) 0 <= (L.L.passenger_door_lock_tenon) 0.95 < && ||
		{if}
			0 (S.L.passenger_door_speed)
		{endif}	 

	        (L.L.passenger_door_pos) (S.L.passenger_door_lastpos)
	
	{endif}

	(L.L.passenger_door_pos) 50 * 108.13 + pi * 180 / sin (S.L.passenger_door_globalangle_X)
	(L.L.passenger_door_pos) 50 * 18.13 + pi * 180 / sin (S.L.passenger_door_globalangle_Y)

	(L.L.passenger_door_pos) 0.83 >=
	{if}
		1 (S.L.PAX_Entry0_Open) (S.L.PAX_Exit0_Open)
	{else}
		0 (S.L.PAX_Entry0_Open) (S.L.PAX_Exit0_Open)
	{endif}

'--------------
'Engine covers:
'--------------

	(L.L.engine_cover_L_dragged) !
	{if}
		(L.L.engine_cover_L_pos) (L.S.Timegap) (L.L.engine_cover_L_speed) * + 80 90 (L.L.engine_cover_R_pos) 170 * - + 170 / min 0 max (S.L.engine_cover_L_pos)

		(L.L.engine_cover_L_pos) 1 >=
		{if}
			(L.L.engine_cover_L_lastpos) 1 <
			{if}
		        	(T.L.emg_door_L_hit)
				1 (S.L.engine_cover_L_pos)
		        {endif}
			(L.L.engine_cover_L_speed) -0.25 * (S.L.engine_cover_L_speed)
		{endif}
		(L.L.engine_cover_L_pos) 0 <=
		{if}
			(L.L.engine_cover_L_lastpos) 0 >
			{if}
		        	(T.L.emg_door_L_hit)
				0 (S.L.engine_cover_L_pos)
		        {endif}
			(L.L.engine_cover_L_speed) -0.25 * (S.L.engine_cover_L_speed)
		{endif}

 		(L.L.engine_cover_L_speed) (L.L.A_Trans_X) /-/ (L.L.engine_cover_L_globalangle_X) * (L.L.A_Trans_Z) /-/ 9.80665 - (L.L.engine_cover_L_globalangle_Z) * + (L.S.Timegap) * + (S.L.engine_cover_L_speed)

		(L.L.engine_cover_L_speed) s1 (S.L.engine_cover_L_lastspeed)
		l1 0 >
		{if}
			l1 (L.S.Timegap) 0.3 * - (S.L.engine_cover_L_speed)
		{endif}
		l1 0 <
		{if}
			l1 (L.S.Timegap) 0.3 * + (S.L.engine_cover_L_speed)
		{endif}

		(L.L.engine_cover_L_speed) 0 > (L.L.engine_cover_L_lastspeed) 0 < &&
		(L.L.engine_cover_L_speed) 0 < (L.L.engine_cover_L_lastspeed) 0 > && ||
		{if}
			0 (S.L.engine_cover_L_speed)
		{endif}	

	        (L.L.engine_cover_L_pos) (S.L.engine_cover_L_lastpos)
	
	{endif}

	(L.L.engine_cover_L_pos) 170 * 20 - pi * 180 / sin (S.L.engine_cover_L_globalangle_X)
	(L.L.engine_cover_L_pos) 170 * 70 + pi * 180 / sin (S.L.engine_cover_L_globalangle_Z)

	(L.L.engine_cover_R_dragged) !
	{if}
		(L.L.engine_cover_R_pos) (L.S.Timegap) (L.L.engine_cover_R_speed) * + 80 90 (L.L.engine_cover_L_pos) 170 * - + 170 / min 0 max (S.L.engine_cover_R_pos)

		(L.L.engine_cover_R_pos) 1 >=
		{if}
			(L.L.engine_cover_R_lastpos) 1 <
			{if}
		        	(T.L.emg_door_L_hit)
				1 (S.L.engine_cover_R_pos)
		        {endif}
			(L.L.engine_cover_R_speed) -0.25 * (S.L.engine_cover_R_speed)
		{endif}
		(L.L.engine_cover_R_pos) 0 <=
		{if}
			(L.L.engine_cover_R_lastpos) 0 >
			{if}
		        	(T.L.emg_door_L_hit)
				0 (S.L.engine_cover_R_pos)
		        {endif}
			(L.L.engine_cover_R_speed) -0.25 * (S.L.engine_cover_R_speed)
		{endif}

 		(L.L.engine_cover_R_speed) (L.L.A_Trans_X) (L.L.engine_cover_R_globalangle_X) * (L.L.A_Trans_Z) /-/ 9.80665 - (L.L.engine_cover_R_globalangle_Z) * + (L.S.Timegap) * + (S.L.engine_cover_R_speed)

		(L.L.engine_cover_R_speed) s1 (S.L.engine_cover_R_lastspeed)
		l1 0 >
		{if}
			l1 (L.S.Timegap) 0.3 * - (S.L.engine_cover_R_speed)
		{endif}
		l1 0 <
		{if}
			l1 (L.S.Timegap) 0.3 * + (S.L.engine_cover_R_speed)
		{endif}

		(L.L.engine_cover_R_speed) 0 > (L.L.engine_cover_R_lastspeed) 0 < &&
		(L.L.engine_cover_R_speed) 0 < (L.L.engine_cover_R_lastspeed) 0 > && ||
		{if}
			0 (S.L.engine_cover_R_speed)
		{endif}	

	        (L.L.engine_cover_R_pos) (S.L.engine_cover_R_lastpos)
	
	{endif}

	(L.L.engine_cover_R_pos) 170 * 20 - pi * 180 / sin (S.L.engine_cover_R_globalangle_X)
	(L.L.engine_cover_R_pos) 170 * 70 + pi * 180 / sin (S.L.engine_cover_R_globalangle_Z)
{end}